package com.tangyuan.test.controller;

import com.mybatisflex.core.paginate.Page;
import com.tangyuan.test.entity.APoliticsSubjectRecordEntity;
import com.tangyuan.test.service.APoliticsSubjectRecordService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;
import java.util.List;

/**
 * 答题记录 控制层。
 * @author TangYuan
 * @since 1.0
 */
@RestController
@RequestMapping("/aPoliticsSubjectRecord")
public class APoliticsSubjectRecordController {
    
    @Resource
    private APoliticsSubjectRecordService aPoliticsSubjectRecordService;
    
    /**
     * 添加 答题记录
     * @param aPoliticsSubjectRecord 答题记录
     * @return {@code true} 添加成功，{@code false} 添加失败
     */
    @PostMapping("/save")
    public boolean save(@RequestBody APoliticsSubjectRecordEntity aPoliticsSubjectRecord) {
        return aPoliticsSubjectRecordService.save(aPoliticsSubjectRecord);
    }
    
    
    /**
     * 根据主键删除答题记录
     * @param id 主键
     * @return {@code true} 删除成功，{@code false} 删除失败
     */
    @DeleteMapping("/remove/{id}")
    public boolean remove(@PathVariable Serializable id) {
        return aPoliticsSubjectRecordService.removeById(id);
    }
    
    
    /**
     * 根据主键更新答题记录
     * @param aPoliticsSubjectRecord 答题记录
     * @return {@code true} 更新成功，{@code false} 更新失败
     */
    @PutMapping("/update")
    public boolean update(@RequestBody APoliticsSubjectRecordEntity aPoliticsSubjectRecord) {
        return aPoliticsSubjectRecordService.updateById(aPoliticsSubjectRecord);
    }
    
    
    /**
     * 查询所有答题记录
     * @return 所有数据
     */
    @GetMapping("/list")
    public List<APoliticsSubjectRecordEntity> list() {
        return aPoliticsSubjectRecordService.list();
    }
    
    
    /**
     * 根据答题记录主键获取详细信息。
     * @param id aPoliticsSubjectRecord主键
     * @return 答题记录详情
     */
    @GetMapping("/getInfo/{id}")
    public APoliticsSubjectRecordEntity getInfo(@PathVariable Serializable id) {
        return aPoliticsSubjectRecordService.getById(id);
    }
    
    
    /**
     * 分页查询答题记录
     * @param page 分页对象
     * @return 分页对象
     */
    @GetMapping("/page")
    public Page<APoliticsSubjectRecordEntity> page(Page<APoliticsSubjectRecordEntity> page) {
        return aPoliticsSubjectRecordService.page(page);
    }
}